How do I solve this "unexpected '}' syntax error" in my bash script?
Posted
by
WASasquatch
on Ask Ubuntu
See other posts from Ask Ubuntu
or by WASasquatch
Published on 2012-07-09T02:05:58Z
Indexed on
2012/07/09
3:22 UTC
Read the original article
Hit count: 230
I have a piece of code that has some serious issues and I was hoping to get it solved soon but no one has offered any help. I thought I'd try some Ubuntu users since this is the OS running the script.
mc_addplugin() {
if pgrep -u $USERNAME -f $SERVICE > /dev/null
then
echo "$SERVICE is running! Please stop the service before adding a plugin."
else
echo "Paste the URL to the .JAR Plugin..."
read JARURL
JARNAME=$(basename "$JARURL")
if [ -d "$TEMPPLUGINS" ]
then
as_user "cd $PLUGINSPATH && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
else
as_user "cd $PLUGINSPATH && mkdir $TEMPPLUGINS && wget -r -A.jar $JARURL -o temp_plugins/$JARNAME"
fi
if [ -f "$TMPDIR/$JARNAME" ]
then
if [ -f "$PLUGINSPATH/$JARNAME" ]
then
if `diff $PLUGINSPATH/$JARNAME $TMPDIR/$JARNAME >/dev/null`
then
echo "You are already running the latest version of $JARNAME."
else
NOW=`date "+%Y-%m-%d_%Hh%M"`
echo "Are you sure you want to overwrite this plugin? [Y/n]"
echo "Note: Your old plugin will be moved to the "$TEMPPLUGINS" folder with todays date."
select yn in "Yes" "No"; do
case $yn in
Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
esac
done
echo "Would you like to start the $SERVICE now? [Y/n]"
select yn in "Yes" "No"; do
case $yn in
Yes ) mc_start; break;;
No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
esac
done
fi
else
echo "Are you sure you want to add this new plugin? [Y/n]"
select yn in "Yes" "No"; do
case $yn in
Yes ) as_user "mv $PLUGINSPATH/$JARNAME $TEMPPLUGINS/${JARNAME}_${NOW} && mv $TEMPPLUGINS/$JARNAME $PLUGINSPATH/$JARNAME"; break;;
No ) echo "The plugin has not been installed! Removing temporary plugin and exiting..."
as_user "rm $TEMPPLUGINS/$JARNAME"; exit;;
esac
done
echo "Would you like to start the $SERVICE now? [Y/n]?"
select yn in "Yes" "No"; do
case $yn in
Yes ) mc_start; break;;
No ) "$SERVICE not running! To start the service run: /etc/init.d/craftbukkit start"; exit;;
esac
done
fi
else
echo "Failed to download the plugin from the URL you specified!"
exit;
fi
}
It throws it at the closing bracket at the end of the function.
© Ask Ubuntu or respective owner